clear
%% PROBLEM
%   'EqualMinima','Himmelblau','Sixhump','ModifiedRastrigin','Vincent',
%   'Shubert','Composition','IncreasingMinima','Rastrigin','Schaffer'.
ProblemSet.FuncType = 'EqualMinima';
ProblemSet.dimension = 1;
% ProblemSet.k = [3,3,3];
% ProblemSet.BaseFunc = 3;

[d, x_bound, ObjFunc, OptSet, ~, ~, PopulationSize, MaximalBudget, FileName]...
    = problem_setting(ProblemSet);

epsilon = [0.1,0.01,0.001,0.0001];
OptSet.fval = -OptSet.fval;
%% problem
Problem.Dimension = d; % the dimension of the decision variable
Problem.LowerBound = x_bound(1,:); % the lower bound of the decision variable
Problem.UpperBound = x_bound(2,:); % the upper bound of the decision variable
Problem.ObjFunc = @(x)(-ObjFunc(x));  % the objective function
%% ALGORITHM
Algorithm.AntSize = PopulationSize;  % the size of the ant
Algorithm.NichSizeSet = 2:20;
Algorithm.std_ls = 1E-4;
Algorithm.N_ls = 2;
Algorithm.MaxFEs = MaximalBudget;%MaximalBudget; % the maximal budget
%%
rep = 100;
TotalBudget = zeros(rep,length(epsilon));
OptNoFound = zeros(rep,length(epsilon));
TotalGeneration = zeros(rep,length(epsilon));
Times = zeros(rep,length(epsilon));
%%
for iepsilon = 1:length(epsilon)
	OptSet.epsilon = epsilon(iepsilon);
    for i = 1:rep
        disp(['epsilon: ',num2str(epsilon(iepsilon)),', replication: ',num2str(i),'.'])
        tic
        [~, EvaluationNum, GenerationNum, OptSetRemain]...
            = lamsaco_test(Problem, Algorithm, OptSet);
        Times(i,iepsilon) = toc;
        disp(['time used: ',num2str(Times(i,iepsilon)),'.'])
        TotalBudget(i,iepsilon) = EvaluationNum;
        OptNoFound(i,iepsilon) = size(OptSetRemain,1);
        TotalGeneration(i,iepsilon) = GenerationNum;
    end
end
%%
save(FileName)
a=[mean(TotalBudget)',var(TotalBudget)'];
